import java.io.*;

/**
 * [简要描述]:
 * [详细描述]:
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/8/10 16:53
 * @since JDK 1.8
 */
public class FileEdier
{

    public static void main(String[] args) throws IOException
    {

        File file = new File("src/main/java/com/company");

        roundFileDir(file);

    }

    private static void roundFileDir(File file) throws IOException
    {
        if (file.isFile())
        {
            editDesc(file);
        }

        File[] files = file.listFiles();

        for (File itemFile : files)
        {
            if (itemFile.isDirectory())
            {
                roundFileDir(itemFile);
            }
            else
            {
                editDesc(itemFile);
            }
        }

    }

    private static void editDesc(File src) throws IOException
    {
        FileReader fileReader = new FileReader(src);

        BufferedReader br = new BufferedReader(fileReader);

        File file = new File("D:\\sourceCode\\designCode\\src\\main\\java\\com\\company\\temp.java");

        FileWriter fileWriter = new FileWriter(file);
        BufferedWriter bw = new BufferedWriter(fileWriter);

        String line; //

        while ((line = br.readLine()) != null)
        {

            bw.newLine();

            if (line.contains("�"))
            {

                StringBuilder sb = new StringBuilder();
                String[] split = line.split("\"");
                if (split != null)
                {
                    for (int i = 0; i < split.length; i++)
                    {
                        if (i % 2 == 0)
                        {
                            sb.append(split[i]);
                        }
                        else
                        {
                            sb.append("=======");
                        }
                    }
                    bw.write(sb.toString());
                }

            }
            else
            {
                bw.write(line);
            }

            bw.flush();
        }

        br.close();
        bw.close();
        src.delete();
        file.renameTo(src);
    }

}
